package com.hopes.bizz.risk.control.dto;

import com.hopes.bizz.risk.control.entity.RiskObjectEntity;
import com.hopes.boss.common.entity.BaseLogicEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import java.util.List;

/**
 * @author daijie
 * @version 1.0
 * @date 2023/7/24 19:23
 * @Description:
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "风险分析对象DTO")
public class RiskObjectDTO extends BaseLogicEntity {
    private static final long serialVersionUID = -8692528334616421362L;

    public RiskObjectEntity toPO() {
        RiskObjectEntity entity = new RiskObjectEntity();
        BeanUtils.copyProperties(this, entity);

        if (!this.deptIdList.isEmpty()) {
            StringBuilder builder = new StringBuilder();
            for (Long id : this.deptIdList) {
                builder.append(id).append(",");
            }
            builder.deleteCharAt(builder.length() - 1);
            entity.setDeptId(builder.toString());
        }

        if (!entity.getHazardSourceFlag()) {
            entity.setHazardSourceLevel(null);
        }

        return entity;
    }

    private Long id;

    private Integer hazardType;

    private String hazardName;

    private String hazardCode;

    private Boolean hazardSourceFlag;

    private Integer riskLevel;

    private Integer riskValue;

    private String riskDesc;

    private Integer afterRiskValue;

    private Integer afterRiskLevel;

    private String afterRiskDesc;

    private List<Long> deptIdList;

    private String postId;

    private String principal;

    private String controlLevel;

    private Long hazardSourceId;

    private Integer hazardSourceLevel;

    private String mainUserId;

    private String techUserId;

    private String operateUserId;

    private String longitude;

    private String latitude;

    private String altitude;

    private String areaScope;

    private String areaDesc;

    private String qrCode;

    private String nfcCode;

    private String remarks;

    private String img;

    private Boolean reportDataFlag;

    private Long orgId;
}
